package com.arpa.oms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;


/**
 * @description 采购单类型：NORMAL普通采购
 *
 * @author leo
 * @date 2020/10/09
 **/
public enum PurchaseTypeEnum implements IEnum<String> {
    // 采购单类型
    NORMAL("NORMAL","普通采购"),
    PURCHASERETURNS("PURCHASERETURNS","采购退货"),

    ALLOCATION("ALLOCATION", "调拨入库"),
    COUNT_SURPLUS("COUNT_SURPLUS", "盘盈入库"),
    INITIALIZATION("INITIALIZATION", "期初入库");

    /**
     * 值
     */
    private final String value;

    /**
     * 描述
     */
    private final String desc;

    PurchaseTypeEnum(final String value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static final Map<String, PurchaseTypeEnum> map = new HashMap();

    static {
        PurchaseTypeEnum[] values = values();
        int length = values.length;
        for(int i = 0; i < length; i++){
            PurchaseTypeEnum value1 = values[i];
            map.put(value1.getValue(),value1);
        }
    }

    public static PurchaseTypeEnum getEnumByValue(String value){

        return map.get(value);
    }

    public static String translate(String value){
        PurchaseTypeEnum item = getEnumByValue(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return this.desc;
    }
}
